VERSION 5.00
Object = "{00025600-0000-0000-C000-000000000046}#5.2#0"; "CRYSTL32.OCX"
Object = "{67397AA1-7FB1-11D0-B148-00A0C922E820}#6.0#0"; "MSADODC.OCX"
Object = "{CDE57A40-8B86-11D0-B3C6-00A0C90AEA82}#1.0#0"; "MSDATGRD.OCX"
Object = "{F0D2F211-CCB0-11D0-A316-00AA00688B10}#1.0#0"; "MSDATLST.OCX"
Begin VB.Form frmpurchase 
   BackColor       =   &H80000002&
   Caption         =   "Purchase"
   ClientHeight    =   6330
   ClientLeft      =   300
   ClientTop       =   2010
   ClientWidth     =   11790
   ControlBox      =   0   'False
   LinkTopic       =   "Form1"
   ScaleHeight     =   6330
   ScaleWidth      =   11790
   StartUpPosition =   2  'CenterScreen
   Begin MSAdodcLib.Adodc Adodc2 
      Height          =   375
      Left            =   7800
      Top             =   0
      Visible         =   0   'False
      Width           =   1200
      _ExtentX        =   2117
      _ExtentY        =   661
      ConnectMode     =   0
      CursorLocation  =   3
      IsolationLevel  =   -1
      ConnectionTimeout=   15
      CommandTimeout  =   30
      CursorType      =   3
      LockType        =   3
      CommandType     =   8
      CursorOptions   =   0
      CacheSize       =   50
      MaxRecords      =   0
      BOFAction       =   0
      EOFAction       =   0
      ConnectStringType=   1
      Appearance      =   1
      BackColor       =   -2147483643
      ForeColor       =   -2147483640
      Orientation     =   0
      Enabled         =   -1
      Connect         =   ""
      OLEDBString     =   ""
      OLEDBFile       =   ""
      DataSourceName  =   ""
      OtherAttributes =   ""
      UserName        =   ""
      Password        =   ""
      RecordSource    =   ""
      Caption         =   "Adodc2"
      BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
         Name            =   "MS Sans Serif"
         Size            =   8.25
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      _Version        =   393216
   End
   Begin Crystal.CrystalReport CrystalReport2 
      Left            =   4800
      Top             =   0
      _ExtentX        =   741
      _ExtentY        =   741
      _Version        =   348160
      PrintFileLinesPerPage=   60
   End
   Begin MSAdodcLib.Adodc Adodc1 
      Height          =   375
      Left            =   6360
      Top             =   0
      Visible         =   0   'False
      Width           =   1335
      _ExtentX        =   2355
      _ExtentY        =   661
      ConnectMode     =   0
      CursorLocation  =   3
      IsolationLevel  =   -1
      ConnectionTimeout=   15
      CommandTimeout  =   30
      CursorType      =   3
      LockType        =   3
      CommandType     =   8
      CursorOptions   =   0
      CacheSize       =   50
      MaxRecords      =   0
      BOFAction       =   0
      EOFAction       =   0
      ConnectStringType=   1
      Appearance      =   1
      BackColor       =   -2147483643
      ForeColor       =   -2147483640
      Orientation     =   0
      Enabled         =   -1
      Connect         =   ""
      OLEDBString     =   ""
      OLEDBFile       =   ""
      DataSourceName  =   "bml"
      OtherAttributes =   ""
      UserName        =   ""
      Password        =   ""
      RecordSource    =   ""
      Caption         =   "Adodc1"
      BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
         Name            =   "MS Sans Serif"
         Size            =   8.25
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      _Version        =   393216
   End
   Begin MSAdodcLib.Adodc ADO1 
      Height          =   375
      Left            =   3120
      Top             =   0
      Visible         =   0   'False
      Width           =   1215
      _ExtentX        =   2143
      _ExtentY        =   661
      ConnectMode     =   0
      CursorLocation  =   3
      IsolationLevel  =   -1
      ConnectionTimeout=   15
      CommandTimeout  =   30
      CursorType      =   3
      LockType        =   3
      CommandType     =   8
      CursorOptions   =   0
      CacheSize       =   50
      MaxRecords      =   0
      BOFAction       =   0
      EOFAction       =   0
      ConnectStringType=   1
      Appearance      =   1
      BackColor       =   -2147483643
      ForeColor       =   -2147483640
      Orientation     =   0
      Enabled         =   -1
      Connect         =   ""
      OLEDBString     =   ""
      OLEDBFile       =   ""
      DataSourceName  =   "bml"
      OtherAttributes =   ""
      UserName        =   ""
      Password        =   ""
      RecordSource    =   ""
      Caption         =   "Adodc1"
      BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
         Name            =   "MS Sans Serif"
         Size            =   8.25
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      _Version        =   393216
   End
   Begin MSDataGridLib.DataGrid DataGrid 
      Bindings        =   "frmpurchase.frx":0000
      Height          =   3255
      Left            =   120
      Negotiate       =   -1  'True
      TabIndex        =   13
      Top             =   2520
      Width           =   11535
      _ExtentX        =   20346
      _ExtentY        =   5741
      _Version        =   393216
      AllowArrows     =   -1  'True
      BackColor       =   -2147483624
      ColumnHeaders   =   -1  'True
      HeadLines       =   1
      RowHeight       =   20
      WrapCellPointer =   -1  'True
      BeginProperty HeadFont {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
         Name            =   "MS Sans Serif"
         Size            =   8.25
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
         Name            =   "VNI-Times"
         Size            =   9.75
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      ColumnCount     =   2
      BeginProperty Column00 
         DataField       =   ""
         Caption         =   ""
         BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED} 
            Type            =   0
            Format          =   ""
            HaveTrueFalseNull=   0
            FirstDayOfWeek  =   0
            FirstWeekOfYear =   0
            LCID            =   1033
            SubFormatType   =   0
         EndProperty
      EndProperty
      BeginProperty Column01 
         DataField       =   ""
         Caption         =   ""
         BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED} 
            Type            =   0
            Format          =   ""
            HaveTrueFalseNull=   0
            FirstDayOfWeek  =   0
            FirstWeekOfYear =   0
            LCID            =   1033
            SubFormatType   =   0
         EndProperty
      EndProperty
      SplitCount      =   1
      BeginProperty Split0 
         BeginProperty Column00 
         EndProperty
         BeginProperty Column01 
         EndProperty
      EndProperty
   End
   Begin VB.CommandButton cmdprint 
      Caption         =   "&Print"
      Height          =   375
      Left            =   960
      TabIndex        =   2
      Top             =   5880
      Width           =   1095
   End
   Begin VB.CommandButton cmdclose 
      Caption         =   "&Close"
      Height          =   375
      Left            =   9480
      TabIndex        =   1
      Top             =   5880
      Width           =   1095
   End
   Begin VB.Frame Frame1 
      BackColor       =   &H80000002&
      Caption         =   "Option"
      ForeColor       =   &H8000000E&
      Height          =   1935
      Left            =   120
      TabIndex        =   0
      Top             =   360
      Width           =   11535
      Begin VB.TextBox Item 
         Height          =   285
         Left            =   2160
         TabIndex        =   20
         Top             =   360
         Visible         =   0   'False
         Width           =   975
      End
      Begin VB.Frame framNf 
         BackColor       =   &H8000000D&
         ForeColor       =   &H8000000E&
         Height          =   975
         Left            =   9000
         TabIndex        =   17
         Top             =   600
         Width           =   2415
         Begin MSDataListLib.DataCombo Bpurno 
            Height          =   315
            Left            =   1200
            TabIndex        =   18
            Top             =   600
            Width           =   1095
            _ExtentX        =   1931
            _ExtentY        =   556
            _Version        =   393216
            ListField       =   "OLPON"
            Text            =   ""
         End
         Begin VB.Label Label6 
            AutoSize        =   -1  'True
            BackColor       =   &H8000000D&
            BackStyle       =   0  'Transparent
            Caption         =   "Purchase No"
            ForeColor       =   &H8000000E&
            Height          =   195
            Left            =   120
            TabIndex        =   19
            Top             =   720
            Width           =   930
         End
      End
      Begin VB.OptionButton PurNof 
         BackColor       =   &H8000000D&
         Caption         =   "By Puschase No Finish"
         ForeColor       =   &H8000000E&
         Height          =   375
         Left            =   9480
         TabIndex        =   16
         Top             =   240
         Width           =   1935
      End
      Begin VB.OptionButton PurNo 
         BackColor       =   &H8000000D&
         Caption         =   "By Purchasr No"
         ForeColor       =   &H8000000E&
         Height          =   375
         Left            =   4920
         TabIndex        =   15
         Top             =   240
         Width           =   1575
      End
      Begin VB.OptionButton PurItem 
         BackColor       =   &H8000000D&
         Caption         =   "By Item No"
         ForeColor       =   &H8000000E&
         Height          =   375
         Left            =   240
         TabIndex        =   14
         Top             =   240
         Width           =   1575
      End
      Begin VB.Frame FramNo 
         BackColor       =   &H8000000D&
         ForeColor       =   &H8000000E&
         Height          =   975
         Left            =   4800
         TabIndex        =   10
         Top             =   600
         Width           =   4215
         Begin MSDataListLib.DataCombo Fno 
            Height          =   315
            Left            =   1080
            TabIndex        =   21
            Top             =   600
            Width           =   1095
            _ExtentX        =   1931
            _ExtentY        =   556
            _Version        =   393216
            ListField       =   "OHPON"
            Text            =   ""
         End
         Begin MSDataListLib.DataCombo Tno 
            Height          =   315
            Left            =   2880
            TabIndex        =   22
            Top             =   600
            Width           =   1215
            _ExtentX        =   2143
            _ExtentY        =   556
            _Version        =   393216
            ListField       =   "OHPON"
            Text            =   ""
         End
         Begin VB.Label Label5 
            AutoSize        =   -1  'True
            BackColor       =   &H8000000D&
            BackStyle       =   0  'Transparent
            Caption         =   "From PurNo"
            ForeColor       =   &H8000000E&
            Height          =   195
            Left            =   120
            TabIndex        =   12
            Top             =   720
            Width           =   840
         End
         Begin VB.Label Label4 
            AutoSize        =   -1  'True
            BackColor       =   &H8000000D&
            BackStyle       =   0  'Transparent
            Caption         =   "To PurNo"
            ForeColor       =   &H8000000E&
            Height          =   195
            Left            =   2160
            TabIndex        =   11
            Top             =   720
            Width           =   690
         End
      End
      Begin VB.Frame FramI 
         BackColor       =   &H8000000D&
         ForeColor       =   &H8000000E&
         Height          =   975
         Left            =   240
         TabIndex        =   3
         Top             =   600
         Width           =   4575
         Begin VB.TextBox Tdate 
            Height          =   285
            Left            =   3120
            TabIndex        =   6
            Top             =   600
            Width           =   1215
         End
         Begin VB.TextBox Fdate 
            Height          =   285
            Left            =   960
            TabIndex        =   5
            Top             =   600
            Width           =   1215
         End
         Begin MSDataListLib.DataCombo BItem 
            Height          =   315
            Left            =   960
            TabIndex        =   4
            Top             =   240
            Width           =   3375
            _ExtentX        =   5953
            _ExtentY        =   556
            _Version        =   393216
            ListField       =   "thitn"
            BoundColumn     =   "Item"
            Text            =   ""
         End
         Begin VB.Label Label3 
            AutoSize        =   -1  'True
            BackColor       =   &H8000000D&
            BackStyle       =   0  'Transparent
            Caption         =   "To Date"
            ForeColor       =   &H8000000E&
            Height          =   195
            Left            =   2400
            TabIndex        =   9
            Top             =   720
            Width           =   585
         End
         Begin VB.Label Label2 
            AutoSize        =   -1  'True
            BackColor       =   &H8000000D&
            BackStyle       =   0  'Transparent
            Caption         =   "From Date"
            ForeColor       =   &H8000000E&
            Height          =   195
            Left            =   120
            TabIndex        =   8
            Top             =   720
            Width           =   735
         End
         Begin VB.Label Label1 
            AutoSize        =   -1  'True
            BackColor       =   &H8000000D&
            BackStyle       =   0  'Transparent
            Caption         =   "Item No:"
            ForeColor       =   &H8000000E&
            Height          =   195
            Left            =   120
            TabIndex        =   7
            Top             =   360
            Width           =   600
         End
      End
   End
End
Attribute VB_Name = "frmpurchase"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Dim WithEvents rst As ADODB.Recordset
Attribute rst.VB_VarHelpID = -1
Dim SQL As String

Private Sub BItem_Change()
    Item = BItem.BoundText
    Dim cmd As New ADODB.Command
    cmd.ActiveConnection = ConnectString
    cmd.CommandType = adCmdText
    cmd.CommandText = "exec purItemdate '" & Format(Fdate.Text, "mm/dd/yyyy") & "','" & Format(Tdate.Text, "mm/dd/yyyy") & "','" & Trim(Item) & "'"
    cmd.Execute
    Adodc1.ConnectionString = ConnectString
    Adodc1.CommandTimeout = 10
    Adodc1.CommandType = adCmdText
    Adodc1.RecordSource = "select * from purno_"
    Adodc1.Refresh
    Set DataGrid.DataSource = Adodc1
End Sub

Private Sub BItem_KeyPress(KeyAscii As Integer)
'    If KeyAscii = 13 Then
'    Fdate.Text = "01/" & Format$(Now(), "mm") & "/" & Format$(Now(), "yyyy")
'    Tdate.Text = Format(Now(), "dd/mm/yyyy")
'    Dim cmd As New ADODB.Command
'    cmd.ActiveConnection = ConnectString
'    cmd.CommandType = adCmdText
'    cmd.CommandText = "exec purItemdate '" & Format(Fdate.Text, "mm/dd/yyyy") & "','" & Format(Tdate.Text, "mm/dd/yyyy") & "','" & Trim(BItem.Text) & "'"
'    cmd.Execute
'    Adodc1.ConnectionString = ConnectString
'    Adodc1.CommandTimeout = 10
'    Adodc1.CommandType = adCmdText
'    Adodc1.RecordSource = "select * from purno_"
'    Adodc1.Refresh
'    Set DataGrid.DataSource = Adodc1
'End If
End Sub

Private Sub Bpurno_Change()
If Bpurno.Text = "" Then
    Dim cmd As New ADODB.Command
    cmd.ActiveConnection = ConnectString
    cmd.CommandType = adCmdText
    cmd.CommandText = "exec purno '" & Trim(Fno.Text) & "','" & Trim(Tno.Text) & "'"
    cmd.Execute
    Adodc1.ConnectionString = ConnectString
    Adodc1.CommandTimeout = 10
    Adodc1.CommandType = adCmdText
    Adodc1.RecordSource = "select * from purno_"
    Adodc1.Refresh
    Set DataGrid.DataSource = Adodc1
Else
    Dim cmd1 As New ADODB.Command
    cmd1.ActiveConnection = ConnectString
    cmd1.CommandType = adCmdText
    cmd1.CommandText = "exec PURnofinishItem '" & Trim(Bpurno.Text) & "'"
    cmd1.Execute
    Adodc1.ConnectionString = ConnectString
    Adodc1.CommandTimeout = 10
    Adodc1.CommandType = adCmdText
    Adodc1.RecordSource = "select * from purno_"
    Adodc1.Refresh
    Set DataGrid.DataSource = Adodc1
End If
End Sub
Private Sub cmdclose_Click()
Unload Me
End Sub

Private Sub cmdPrint_Click()
If PurItem.value = True Then
    CrystalReport2.ReportFileName = "Z:\ReportItem.rpt"
    CrystalReport2.RetrieveStoredProcParams
    CrystalReport2.StoredProcParam(0) = Format$(Trim(Fdate.Text), "mm/dd/yyyy")
    CrystalReport2.StoredProcParam(1) = Format$(Trim(Tdate.Text), "mm/dd/yyyy")
    CrystalReport2.StoredProcParam(2) = Trim(Item.Text)
    CrystalReport2.Destination = crptToWindow
    CrystalReport2.Action = 1
End If
If PurNo.value = True Then
    CrystalReport2.ReportFileName = "Z:\ReportPurchaseOrder.rpt"
    CrystalReport2.RetrieveStoredProcParams
    CrystalReport2.StoredProcParam(0) = Trim(Fno.Text)
    CrystalReport2.StoredProcParam(1) = Trim(Tno.Text)
    CrystalReport2.Destination = crptToWindow
    CrystalReport2.Action = 1
End If
If PurNof.value = True Then
    CrystalReport2.ReportFileName = "Z:\ReportByPONofinish.rpt"
    CrystalReport2.RetrieveStoredProcParams
    CrystalReport2.StoredProcParam(0) = Trim(Bpurno.Text)
    CrystalReport2.Destination = crptToWindow
    CrystalReport2.Action = 1
End If
End Sub


Private Sub Fdate_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
    If IsDate(Fdate.Text) = True Then
    Tdate.SetFocus
     Else
      'Debug.Print "err"
        MsgBox "Incorrect Date in the FromDate Textbox", vbCritical, "Warning..."
        Exit Sub
    End If
End If
End Sub


Private Sub Fno_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
    If IsNumeric(Fno.Text) = True Then
        Tno.SetFocus
    Else
        MsgBox "You must enter numeric", vbCritical, "Warning"
        Exit Sub
    End If
End If
End Sub

Private Sub Form_Load()
Dim cmd2 As New ADODB.Command
cmd2.ActiveConnection = ConnectString
cmd2.CommandType = adCmdText
cmd2.CommandText = "delete from purno_"
cmd2.Execute
FramI.Enabled = False
FramNo.Enabled = False
cmdprint.Enabled = False
PurItem.value = False
PurNo.value = False
PurNof.value = False

End Sub

Private Sub PurItem_Click()
    Fdate.Text = "01/" & Format$(Now(), "mm") & "/" & Format$(Now(), "yyyy")
    Tdate.Text = Format$(Now(), "dd/mm/yyyy")
    SQL = ""
    SQL = SQL & "SELECT distinct dbo.IIM.IMITN as Item,dbo.IIM.IMITN + ' : ' + dbo.IIM.IMITD AS thitn "
    SQL = SQL & "FROM dbo.POL INNER JOIN dbo.IIM ON dbo.POL.OLITN = dbo.IIM.IMITN "
    SQL = SQL & "where  (dbo.POL.OLLDT >= '" & Format(Fdate.Text, "mm/dd/yyyy") & "' AND dbo.POL.OLLDT<='" & Format(Tdate.Text, "mm/dd/yyyy") & "')"
   ' SQL = SQL & " order by dbo.IIM.IMITD"
    ADO1.ConnectionString = ConnectString
    ADO1.CommandTimeout = 10
    ADO1.CommandType = adCmdText
    ADO1.RecordSource = SQL
    ADO1.Refresh
    Set BItem.RowSource = ADO1
    FramI.Enabled = True
    FramNo.Enabled = False
    BItem.SetFocus
    BItem.Text = ""
    Fno.Text = ""
    Tno.Text = ""
    Bpurno.Text = ""
    Set DataGrid.DataSource = Nothing
    cmdprint.Enabled = True
    PurItem.value = True
    PurNo.value = False
    PurNof.value = False
End Sub
Private Sub PurNo_Click()
PurItem.value = False
PurNo.value = True
PurNof.value = False
Set DataGrid.DataSource = Nothing
FramI.Enabled = False
FramNo.Enabled = True
Fno.SetFocus
BItem.Text = ""
Fdate.Text = ""
Tdate.Text = ""
Fno.Text = ""
Tno.Text = ""
Bpurno.Text = ""
cmdprint.Enabled = True
Adodc2.ConnectionString = ConnectString
Adodc2.ConnectionTimeout = 10
Adodc2.CommandType = adCmdText
Adodc2.RecordSource = "Select OHPON from POH where isnumeric(OHPON)=1 ORDER BY OHPON DESC"
Adodc2.Refresh
Set Fno.RowSource = Adodc2
Set Tno.RowSource = Adodc2
End Sub
Private Sub PurNof_Click()
PurItem.value = False
PurNo.value = False
PurNof.value = True
SQL = "SELECT  DISTINCT OLPON FROM POH INNER JOIN "
SQL = SQL & "POL ON POH.OHPON = POL.OLPON "
SQL = SQL & "WHERE     (POH.OHPOS = '1') OR  (POH.OHPOS = '2') OR  (POH.OHPOS = '3') OR (POH.OHPOS = '4')"
ADO1.ConnectionString = ConnectString
ADO1.CommandTimeout = 10
ADO1.CommandType = adCmdText
ADO1.RecordSource = SQL
ADO1.Refresh
Set Bpurno.RowSource = ADO1
Set DataGrid.DataSource = Nothing
FramI.Enabled = False
FramNo.Enabled = False
BItem.Text = ""
Fdate.Text = ""
Tdate.Text = ""
Fno.Text = ""
Tno.Text = ""
Bpurno.SetFocus
Dim cmd As New ADODB.Command
cmd.ActiveConnection = ConnectString
cmd.CommandType = adCmdText
cmd.CommandText = "exec PURnofinish"
cmd.Execute
Adodc1.ConnectionString = ConnectString
Adodc1.CommandTimeout = 10
Adodc1.CommandType = adCmdText
Adodc1.RecordSource = "select * from purno_"
Adodc1.Refresh
Set DataGrid.DataSource = Adodc1
cmdprint.Enabled = True
End Sub
Private Sub Tdate_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
    If IsDate(Tdate.Text) = True Then
        Dim cmd As New ADODB.Command
        cmd.ActiveConnection = ConnectString
        cmd.CommandType = adCmdText
        cmd.CommandText = "exec purItemdate '" & Format(Trim(Fdate.Text), "mm/dd/yyyy") & "','" & Format(Trim(Tdate.Text), "mm/dd/yyyy") & "','" & Trim(Item.Text) & "'"
        cmd.Execute
        Adodc1.ConnectionString = ConnectString
        Adodc1.CommandTimeout = 10
        Adodc1.CommandType = adCmdText
        Adodc1.RecordSource = "select * from purno_"
        Adodc1.Refresh
        Set DataGrid.DataSource = Adodc1
    Else
        MsgBox "Incorrect Date in the ToDate Textbox", vbCritical, "Warning..."
        Exit Sub
    End If
End If
End Sub


Private Sub TNo_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
    If IsNumeric(Tno.Text) = True Then
        Dim cmd As New ADODB.Command
        cmd.ActiveConnection = ConnectString
        cmd.CommandType = adCmdText
        cmd.CommandText = "exec purno '" & Trim(Fno.Text) & "','" & Trim(Tno.Text) & "'"
        cmd.Execute
        Adodc1.ConnectionString = ConnectString
        Adodc1.CommandTimeout = 10
        Adodc1.CommandType = adCmdText
        Adodc1.RecordSource = "select * from purno_"
        Adodc1.Refresh
        Set DataGrid.DataSource = Adodc1
    Else
        MsgBox "You must enter numeric in Textbox", vbCritical, "Warning..."
        Exit Sub
    End If
End If
End Sub
